package com.pijunn.feedback

import com.pijunn.common.template.TemplateHolder;

class FeedbackController {

	def emailerService
	def springSecurityService
	
    def index() {
		sendFeedback()
	}
	
	def sendFeedback() {
		if (!params['feedbackEmail']) {
			def user = springSecurityService.currentUser
			params.put('feedbackEmail', user.firstName + ' ' + user.lastName + ' (' + user.contactEMail + ')')
		}
		def feedback = params
		def h = new TemplateHolder([bindingName: 'feedback', to: ['support@pijunn.com'], subject: "User Feedback", binding: feedback]);

		log.info("Sending Feedback E-mail from: " + params['feedbackEmail'])
		emailerService.sendNotificationEmail(h)
	}
}
